package quickstart

import org.apache.spark.sql.SparkSession

/**
  * Created by ade on 2017/10/10.
  */
object SimpleApp {
  def main(args: Array[String]) {
    // 本地执行 args(0) = file/1.txt
    val logFile = args(0) // Should be some file on your system
    val spark = SparkSession.builder.appName("SimpleApplication").getOrCreate()
    //.master("local[2]")
    val sc = spark.sparkContext
    val logData = sc.textFile(logFile).cache()
    val numAs = logData.filter(line => line.contains("a")).count()
    val numBs = logData.filter(line => line.contains("b")).count()
    println(s"Lines with a: $numAs, Lines with b: $numBs")
    spark.stop()
  }
}
